package cn.gyx.hrm.web.controller;

import cn.gyx.hrm.dto.SMSCodeDto;
import cn.gyx.hrm.service.VipVerifycodeService;
import cn.gyx.hrm.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class VipVerifycodeController {
    @Autowired
    private VipVerifycodeService vipVerifycodeService;

    // 验证码验证
    @RequestMapping(value = "/imageCode/{key}",method = RequestMethod.GET)
    public AjaxResult verifycode(@PathVariable String key) {
        String result = vipVerifycodeService.creatImgcode(key);
         return AjaxResult.me().setResultObj(result);
     }

    // 短信验证码验证
    @RequestMapping(value = "/sendSmsCode",method = RequestMethod.POST)
    public AjaxResult sendSmsCode(@Valid @RequestBody SMSCodeDto dto) {
        vipVerifycodeService.sendSmsCode(dto);
        return AjaxResult.me();
    }
}
